package top.humbleyuan.test;

import org.junit.Test;
import top.humbleyuan.test.Entity.MyCache;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author HumbleYuan
 * @Date 2019/10/9 14:42
 * @Des
 */
public class Try {

    /**
     * 线程安全
     */
    @Test
    public void try1() {
        ExecutorService threadPool = Executors.newFixedThreadPool(200);

        MyCache myCache = new MyCache();
        for(int i = 0;i < 200;i++) {
            threadPool.execute(() -> {

                if(myCache.getCache() == null) {
                    System.out.println("***");
                    return;
                }
                System.out.println("not null");
            });
        }

        threadPool.shutdown();
    }
}
